#include "../comm.h"
class Solution {
public:
    vector<int> missingRolls(vector<int>& rolls, int mean, int n) {
        int m = rolls.size();
        int sum = 0;
        for(auto e: rolls) sum += e;
        int ret = mean * (n + m) - sum;
        vector<int> ans(n, 6);
        if(ret > 6 * n || ret < n) return {};
        // 分配每个值在 1 ~ 6 之间，并且总和为ret
        int now = n * 6;
        for(int i = 0; i < n; ++i)
        {
            if(now > ret)
            {
                ans[i] = max(1, 6 - (now - ret));
                now -= 6 - ans[i];
            }
        }
        return ans;
    }
};